package com.fasc.open.api.client;

import com.fasc.open.api.bean.base.BaseRes;
import com.fasc.open.api.bean.req.file.UploadInstantReq;
import com.fasc.open.api.bean.res.file.UploadInstantRes;
import com.fasc.open.api.constants.OpenApiUrlConstants;
import com.fasc.open.api.exception.ApiException;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Fadada
 * 2021/9/8 16:09:38
 */
public class FileClient {
    private OpenApiClient openApiClient;

    public FileClient(OpenApiClient openApiClient) {
        this.openApiClient = openApiClient;
    }

    public BaseRes<UploadInstantRes> uploadInstantFile(File fileContent, UploadInstantReq req) throws ApiException {
        Map<String, File> fileMap = new HashMap<>(1);
        if (fileContent != null) {
            fileMap.put(OpenApiUrlConstants.FILE_UPLOAD_INSTANT_FILE_KEY, fileContent);
        }
        return openApiClient.invokeApi(req, OpenApiUrlConstants.FILE_UPLOAD_INSTANT, fileMap, UploadInstantRes.class);
    }

}
